package thread;
//关于定时器的使用案列
import java.util.Timer;
import java.util.TimerTask;

public class testDemo23 {
    public static void main(String[] args) throws InterruptedException {
        Timer timer=new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("此时时间为3秒后");
            }
        },3000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("此时时间为2秒后");
            }
        },2000);

        Thread.sleep(3000);
        timer.cancel();
    }
}
